package edu.tgc.service;

import org.springframework.data.domain.AuditorAware;

import edu.tgc.entity.system.SysUser;
import edu.tgc.security.SessionUser;
import edu.tgc.security.SessionUserUtils;

public class UserAuditorService implements AuditorAware<SysUser> {

    @Override
    public SysUser getCurrentAuditor() {
        SessionUser sessionUser = SessionUserUtils.getSessionUser();
        if (sessionUser == null || sessionUser.getId() == null) {
            return null;
        } else {
            return new SysUser(sessionUser.getId());
        }
    }

}
